<template>
  <el-card class="box-card">
    <div slot="header" class="clearfix">
      <span>设置部门权重 </span>
      <el-tooltip class="item" effect="dark" content="权重值越大越优先，权重值为空不会被分配数据" placement="right">
        <i class="el-icon-warning-outline" style="color: #409eff"></i>
      </el-tooltip>
    </div>
    <div class="text item" v-loading="loadingTeam">
      <el-form ref="form" :inline="true" label-width="100px">
        <el-form-item v-for="(item,i) in TeamArr" :key="item.id" :label="item.name">
          <el-input type="number" v-model="item.weightOrderNum" placeholder="请输入权重值"></el-input>
        </el-form-item>
        <el-row style="text-align: center">
          <el-form-item>
            <el-button type="primary" @click="getDataQuanSub">保存</el-button>
          </el-form-item>
        </el-row>
      </el-form>
    </div>
  </el-card>
</template>

<script>
import { RootIndexTeaminit, RootIndexQuanSub } from '../../../../api/index';
export default {
  data() {
    return {
      loadingTeam: false,
      TeamArr: [],
      cityArrOption: [],
    };
  },
  created() {
    this.getDataTeamInit();
  },
  methods: {
    //获取公海初始化数据
    getDataTeamInit() {
      this.loadingTeam = true;
      RootIndexTeaminit().then((res) => {
        this.loadingTeam = false;
        if (res.code === 0) {
          this.TeamArr = res.teamList;
        } else {
          this.$message(res.msg);
        }
      });
    },
    //提交公海设置
    getDataQuanSub() {
      this.loadingTeam = true;
      let arr = [];
      this.TeamArr.forEach((item, i) => {
        arr.push({
          wUserId: item.id,
          orderNum: item.weightOrderNum,
        })
      })
      RootIndexQuanSub({ weightList: arr, type: '1' }).then((res) => {
        this.loadingTeam = false;
        if (res.code === 0) {
          this.$message.success("设置成功");
        } else {
          this.$message(res.msg);
        }
      });
    },
    //获取所属城市
    getDataCity() {
      RootIndexTeamCity().then((res) => {
        if (res.code === 0) {
          this.cityArrOption = res.cityArr;
        } else {
          this.$message(res.msg);
        }
      });
    },
  }
};
</script>

<style scoped>
.box-card {
    margin-bottom: 20px;
}
.mar-10 {
    margin-bottom: 10px;
}
.el-radio {
    margin-right: 5px;
}
.fontColor {
    font-size: 12px;
    color: #999;
    margin-bottom: 20px;
}
</style>
